package bootstrap

import (
	"github.com/eatmoreapple/openwechat"
	"log"
	"wechat/gpt/client/handler"
)

func Run() {

	bot := openwechat.DefaultBot(openwechat.Desktop)

	// 注册消息处理函数
	bot.MessageHandler = handler.Handler

	// 注册二维码登录回调
	bot.UUIDCallback = handler.QrCodeCallback

	// 创建热存储容器对象
	reloadStorage := openwechat.NewJsonFileHotReloadStorage("storage.json")

	// 执行热登录
	err := bot.HotLogin(reloadStorage)
	if err != nil {
		if err = bot.Login(); err != nil {
			log.Printf("login error: %v\n", err)
			return
		}
	}

	bot.Block()
}
